#include "croot.h"
#include "cmanageddecoration.h"

#include <buola/gui/x11/cx11display.h>
#include <buola/gui/x11/cpixmap.h>

namespace buola { namespace bwm {

CManagedDecoration::CManagedDecoration(CClient *pClient)
    :   CPixmapDecoration(pClient)
    ,   mActive(false)
{
}

CManagedDecoration::~CManagedDecoration()
{
}

void CManagedDecoration::OnClientActivated(bool pActive)
{
    mActive=pActive;
    Refresh();
}
                    
void CManagedDecoration::OnStateChanged(int pState,int pOld)
{
}

void CManagedDecoration::OnLabelChanged()
{
    Refresh();
}

void CManagedDecoration::OnDesktopSwitched()
{
}

void CManagedDecoration::OnButtonDown(const CPoint_d &pP,gui::EMouseButton pButton,int pMods)
{
    CPoint_d lPoint=pP-CPoint_d(mClientXPos);

    eActivate();

    if(pButton==gui::EMouseButton::LEFT)
    {
        eDrag(GetDraggingZone(lPoint),pP,pButton);
    }
    else if(pButton==gui::EMouseButton::RIGHT)
    {
        eShowMenu(pP);
    }
    else if(pButton==gui::EMouseButton::MIDDLE)
    {
//      SetOpacity(0.2);
    }
}

void CManagedDecoration::OnButtonUp(const CPoint_d &pP,gui::EMouseButton pButton,int pMods)
{
    if(pButton==gui::EMouseButton::LEFT)
    {
        //the mouse might be released before the client has grabbed it
        //in this case, cancel the drag
        eDragCancel();
    }
    if(pButton==gui::EMouseButton::MIDDLE)
    {
        OnOpacityChanged();
    }
}

void CManagedDecoration::OnMouseMove(const CPoint_d &pP)
{
}

void CManagedDecoration::OnMouseOut()
{
//  RestoreCursor();
}

/*namespace bwm*/ } /*namespace buola*/ }
